﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace gChartSharp
{
    /// <summary>
    /// http://code.google.com/apis/chart/#chtt
    /// </summary>
    public class ChartTitle : IChartParam
    {
        /// <summary>
        /// The name of the API
        /// </summary>
        public string Name { get { return "chtt"; } }


        /// <summary>
        /// The title of the chart
        /// </summary>
        public string Title
        {
            get { return mTitle; }
            set
            {
                mTitle = value.Replace(' ', '+').Replace("\n", "|");
            }
        }
        private string mTitle;


        /// <summary>
        /// Hide default constructor
        /// </summary>
        private ChartTitle() { }


        /// <summary>
        /// The only constructor in town
        /// </summary>
        /// <param name="title"></param>
        public ChartTitle(string title)
        {
            this.Title = title;
        }

        /// <summary>
        /// Render the chart parameter
        /// </summary>
        /// <returns></returns>
        public string Render()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(String.Format("&{0}={1}", this.Name, this.Title));

            return sb.ToString();
        }
    }
}
